package main.java.indi.zyj.sword;

import main.java.indi.zyj.hot100.base.TreeNode;

public class CheckSymmetricTree {

    public boolean checkSymmetricTree(TreeNode root) {

        if (root == null) {
            return true;
        }

        return helper(root.left, root.right);

    }

    private boolean helper(TreeNode root1, TreeNode root2) {

        if (root1 == null && root2 == null)
            return true;
        if (root1 == null || root2 == null)
            return false;
        return root1.val == root2.val && helper(root1.left, root2.right) &&
                helper(root1.right, root2.left);

    }

}
